package com.ruoyi.biz.service.caseinfo.impl;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.apache.shiro.util.CollectionUtils;
import org.springframework.stereotype.Service;

import com.ruoyi.biz.domain.CaseInfoCust;
import com.ruoyi.biz.mapper.CaseInfoCustMapper;
import com.ruoyi.biz.service.caseinfo.ICaseInfoCustService;
import com.ruoyi.comm.crud.service.impl.BaseImpls;

/**
 * 案件类型信息 服务层处理
 * 
 * @author riverbo
 */
@Service
public class CaseInfoCustServiceImpl extends BaseImpls<CaseInfoCustMapper, CaseInfoCust> implements ICaseInfoCustService {

//	@Override
//	public Boolean checkNameUnique(CaseType t) {
//        Long boId = StringUtils.isNull(t.getCaseTypeId()) ? -1L : t.getCaseTypeId();
//        Long dbId = this.baseMapper.getIdByName(t);
//        if (StringUtils.isNotNull(dbId) && dbId.longValue() != boId.longValue()) {
//            return UserConstants.NOT_UNIQUE;
//        }
//        return UserConstants.UNIQUE;
//	}
	
	public Map<Integer, List<CaseInfoCust>> getMap(Integer caseId) {
		Map<Integer, List<CaseInfoCust>> map = null;
		List<CaseInfoCust> list = this.selectListById(caseId);
		if (!CollectionUtils.isEmpty(list)) {
			map = new LinkedHashMap<>();
			for (CaseInfoCust u : list) {
				List<CaseInfoCust> ls = map.get(u.getCaseCustType());
				if (ls == null) {
					ls = new ArrayList<>();
				}
				ls.add(u);
				map.put(u.getCaseCustType(), ls);
			}
		}
		return map;
	}
	
	public int insert(Integer id, List<CaseInfoCust> list) {
		if (!CollectionUtils.isEmpty(list)) {
			for (CaseInfoCust u : list) {
				u.setCaseId(id);
			}
			return super.insert(list);
		} else {
			return 0;
		}
	}
	
}
